package vistas;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.plaf.LabelUI;
import javax.swing.JMenuBar;
import javax.swing.JToolBar;
import javax.swing.JDesktopPane;
import javax.swing.JLabel;
import javax.swing.BoxLayout;
import javax.swing.Timer;

import java.awt.GridLayout;
import java.awt.CardLayout;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;

import clases.Utilidades_class;

import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.RowSpec;
import net.miginfocom.swing.MigLayout;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import javax.swing.SwingConstants;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Date;
import javax.swing.ImageIcon;
import javax.swing.JMenu;
import javax.swing.JMenuItem;

public class Principal_form extends JFrame {

	
	private JPanel contentPane;
	private String codigogestor;
	private String nombregestor;
	private Utilidades_class utilidades;
	private JLabel lblhora;
	private JLabel lbliconostatus;
	private JLabel lblstatus;
	
	
	/**
	 * Launch the application.
	 */
	
	
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Principal_form frame = new Principal_form("","");
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public Principal_form(final String codigogestor, String nombregestor) {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 671, 433);
		
		JMenuBar menuBar = new JMenuBar();
		setJMenuBar(menuBar);
		
		JMenu menu = new JMenu("New menu");
		menuBar.add(menu);
		
		JMenuItem menuItem = new JMenuItem("New menu item");
		menuItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				COBROS_buscar prueba = new COBROS_buscar(codigogestor);
				prueba.setVisible(true);
			}
		});
		menu.add(menuItem);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		
		JToolBar toolBar_1 = new JToolBar();
		toolBar_1.setFloatable(false);
		contentPane.add(toolBar_1, BorderLayout.SOUTH);
		
		lbliconostatus = new JLabel("");
		lbliconostatus.setIcon(new ImageIcon(Principal_form.class.getResource("/images/status_ok.png")));
		toolBar_1.add(lbliconostatus);
		
		lblstatus = new JLabel("   Listo");
		lblstatus.setFont(new Font("Arial", Font.PLAIN, 12));
		toolBar_1.add(lblstatus);
		
		JDesktopPane desktopPane = new JDesktopPane();
		contentPane.add(desktopPane, BorderLayout.CENTER);
		
		JPanel panel = new JPanel();
		panel.setPreferredSize(new Dimension(0, 25));
		panel.setMinimumSize(new Dimension(50, 50));
		panel.setBounds(new Rectangle(0, 0, 100, 50));
		contentPane.add(panel, BorderLayout.NORTH);
		panel.setLayout(null);
		
		JLabel label = new JLabel("<dynamic>");
		label.setFont(new Font("Arial", Font.PLAIN, 13));
		label.setBounds(58, 0, 65, 15);
		panel.add(label);
		
		JLabel label_1 = new JLabel("Usuario:");
		label_1.setFont(new Font("Arial", Font.PLAIN, 13));
		label_1.setBounds(10, 0, 48, 15);
		panel.add(label_1);
		
		lblhora = new JLabel("[hora]");
		lblhora.setFont(new Font("Arial", Font.PLAIN, 13));
		lblhora.setBounds(396, 1, 239, 15);
		panel.add(lblhora);
//		setExtendedState(MAXIMIZED_BOTH);
		
		/*INICIALIZAR LAS VARIABLES*/
		{
			this.codigogestor=codigogestor;
			this.nombregestor=nombregestor;
			utilidades = new Utilidades_class();
		}
		//TIMER PARA LA HORA
		Timer timer = new Timer(1000, new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				lblhora.setText(utilidades.mostrarfechahora(new Date()));
			}
		});
		timer.start();
	}
}
